package singleton;

/**
 * 懒汉模式
 */
class lazySingleton {
    private static lazySingleton instance = null;

    private lazySingleton(){}

    public static lazySingleton getInstance() {
        if (instance == null) {
            instance = new lazySingleton();
        }
        return instance;
    }
}

public class demo2 {
    public static void main(String[] args) {
        lazySingleton s1 = lazySingleton.getInstance();
        lazySingleton s2 = lazySingleton.getInstance();
        System.out.println(s1 == s2);
    }
}
